<?php
class Current_specials_model extends Model
{
    function __construct()
    {
        parent::__construct();
        //$this->output->enable_profiler(TRUE);
    }
    
    function getContentPage()
    {
        $this->load->database();
        $query = $this->db->get_where('bur_staticpages',array('staticpage_link'=>'current_specilals'));
        return $query->result();
    }
    
    function checkSubscriber($email, $status)
    {
        $this->load->database();
       
        if($status == 1)
        {
           $query = $this->db->get_where('bur_subscribers',array('subscriber_email'=>$email,'status' => '1'));
            
            if(is_array($query->result_array()) && $query->num_rows() > 0 )
              {
                  //return "that e-mail already exists in the database";
                  
                  return false;
              }
              else
              {
                  
                 
                  $query1 = $this->db->get_where('bur_subscribers',array('subscriber_email'=>$email,'status' => '0'));
                  if(is_array($query1->result_array()) && $query1->num_rows() > 0)
                  {
                      
                      $this->db->update('bur_subscribers',array('status'=>'1'),array('subscriber_email'=>$email));
                      
                  }
                  else
                  {
                        
                        $arr = array('subscriber_email'=>$email,'status' => '1');                                    
                        $this->db->insert('bur_subscribers',$arr);
                    }      
                    
                return 1;
            }
        }
        else
        {
            $query = $this->db->get_where('bur_subscribers',array('subscriber_email'=>$email,'status' => '1'));
            if($query->num_rows() > 0 && is_array($query->result_array()))
            {
                $this->db->update('bur_subscribers',array('status'=> '0'),array('subscriber_email'=>$email));
                //return "success - you unscribed.";
                return 1;
                
                
            }
            else
            {
                return false;
                //return "that e-mail does not exist in the database";
            }
        }
        
        
    }
    
}
?>